package com.star.oauth.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class LoginController{

    @RequestMapping(value = "/login")
     public Object login(@RequestParam(value = "username") String username,
                @RequestParam(value = "password") String password){
            Subject subject = SecurityUtils.getSubject();
            subject.login(new UsernamePasswordToken(username, password));
            Object principal = SecurityUtils.getSubject().getPrincipal();
            return principal;
        }

}
